package cd.cdyb.sms.controller;

import cd.cdyb.sms.dto.MessageRecordingDto;
import cd.cdyb.sms.dto.MessageRecordingStatisticsDto;
import cd.cdyb.sms.dto.PageResult;
import cd.cdyb.sms.dto.query.MessageRecordingQueryDto;
import cd.cdyb.sms.exception.BusinessException;
import cd.cdyb.sms.service.MessageRecordingService;
import cd.cdyb.sms.utils.UserUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * @Author: lilin
 * @CreateTime: 2024-05-17  17:13
 * @Description: 短信发送记录
 */
@RestController
@RequestMapping("/messageRecording")
public class MessageRecordingController {

    @Resource
    private MessageRecordingService messageRecordingService;


    /**
     * 客户端 统计 分页
     */
    @PostMapping("/messageRecordingStatisticsPageWithClient")
    public Map<String, Object> messageRecordingStatisticsPageWithClient(@RequestBody @Valid MessageRecordingQueryDto messageRecordingQueryDto) throws BusinessException {
        messageRecordingQueryDto.setCompanyId(UserUtils.getCompanyId());
        return messageRecordingService.messageRecordingStatisticsPageWithClient(messageRecordingQueryDto);
    }

    /**
     * 管理端 统计 分页
     */
    @PostMapping("/messageRecordingStatisticsPageWithAdmin")
    public Map<String, Object> messageRecordingStatisticsPageWithAdmin(@RequestBody @Valid MessageRecordingQueryDto messageRecordingQueryDto) {
        return messageRecordingService.messageRecordingStatisticsPageWithClient(messageRecordingQueryDto);
    }

    /**
     * 客户端 记录 分页
     */
    @PostMapping("/messageRecordingPageWithClient")
    public PageResult<MessageRecordingDto> messageRecordingPageWithClient(@RequestBody MessageRecordingQueryDto messageRecordingQueryDto) throws BusinessException {
        messageRecordingQueryDto.setCompanyId(UserUtils.getCompanyId());
        return messageRecordingService.messageRecordingPageWithClient(messageRecordingQueryDto);
    }

    /**
     * 管理端 记录 分页
     */
    @PostMapping("/messageRecordingPageWithAdmin")
    public PageResult<MessageRecordingDto> messageRecordingPageWithAdmin(@RequestBody MessageRecordingQueryDto messageRecordingQueryDto) {
        return messageRecordingService.messageRecordingPageWithClient(messageRecordingQueryDto);
    }


    /**
     * 客户端 统计
     */
    @PostMapping("/indexStatistics")
    public MessageRecordingStatisticsDto indexStatistics(@RequestBody  MessageRecordingQueryDto messageRecordingQueryDto) throws BusinessException {
        messageRecordingQueryDto.setCompanyId(UserUtils.getCompanyId());
        return messageRecordingService.indexStatistics(messageRecordingQueryDto);
    }
}
